﻿using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Joy.Erp.BasicArchives.Core.Filters;

namespace Joy.Erp.BasicArchives.Production
{
    [RemoteService(Name = BasicArchivesRemoteServiceConsts.RemoteServiceName)]
    [Area(BasicArchivesRemoteServiceConsts.ModuleName)]
    [ControllerName("PlanOrder")]
    [Route("api/basic-archives/plan-order")]
    public partial class PlanOrderController : BasicArchivesController, IPlanOrderAppService
    {
        protected IPlanOrderAppService PlanOrderAppService => LazyServiceProvider.LazyGetRequiredService<IPlanOrderAppService>();

        [HttpGet]
        [Route("{id}")]
        public Task<PlanOrderDto> GetAsync(Guid id)
        {
            return PlanOrderAppService.GetAsync(id);
        }

        [HttpGet]
        [Route("child/{id}")]
        public Task<PlanOrderPreparationDto> GetChildAsync(Guid id)
        {
            return PlanOrderAppService.GetChildAsync(id);
        }

        [HttpGet]
        [Route("find")]
        public Task<PlanOrderDto> FindAsync(string filter)
        {
            return PlanOrderAppService.FindAsync(filter);
        }

        [HttpGet]
        [Route("find-by-source-key")]
        public Task<PlanOrderDto> FindBySourceKeyAsync(string sourceKey, string sourceType)
        {
            return PlanOrderAppService.FindBySourceKeyAsync(sourceKey, sourceType);
        }

        [HttpGet]
        public Task<PagedResultDto<PlanOrderDto>> GetListAsync(FilterRequestDto input)
        {
            return PlanOrderAppService.GetListAsync(input);
        }

        [HttpPost]
        [Route("query")]
        public Task<PagedResultDto<PlanOrderDto>> QueryAsync(FilterGroupRequestDto input)
        {
            return PlanOrderAppService.QueryAsync(input);
        }

        [HttpPost]
        [Route("query-children")]
        public Task<PagedResultDto<PlanOrderPreparationDto>> QueryChildrenAsync(FilterGroupRequestDto input)
        {
            return PlanOrderAppService.QueryChildrenAsync(input);
        }

        [HttpPost]
        public Task<PlanOrderDto> CreateAsync(PlanOrderCreateDto input)
        {
            return PlanOrderAppService.CreateAsync(input);
        }

        [HttpPut]
        [Route("{id}")]
        public Task<PlanOrderDto> UpdateAsync(Guid id, PlanOrderUpdateDto input)
        {
            return PlanOrderAppService.UpdateAsync(id, input);
        }

        [HttpPost]
        [Route("submit")]
        public Task<PlanOrderDto> SubmitAsync(Guid id)
        {
            return PlanOrderAppService.SubmitAsync(id);
        }

        [HttpPost]
        [Route("approve")]
        public Task<PlanOrderDto> ApproveAsync(Guid id)
        {
            return PlanOrderAppService.ApproveAsync(id);
        }

        [HttpPost]
        [Route("unapprove")]
        public Task<PlanOrderDto> UnApproveAsync(Guid id)
        {
            return PlanOrderAppService.UnApproveAsync(id);
        }

        [HttpDelete]
        [Route("{id}")]
        public Task DeleteAsync(Guid id)
        {
            return PlanOrderAppService.DeleteAsync(id);
        }
    }
}